package com.myres.struts2.action;

import java.util.List;

import com.myres.model.Shop;
import com.myres.service.ShopService;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class GetShopListAction extends ActionSupport {
	private List<Shop> shops;
	private ShopService getShopListService;
	private String [] shopList_String;
	private String aa;
	
	
	public String getAa() {
		return aa;
	}

	public void setAa(String aa) {
		this.aa = aa;
	}

	public GetShopListAction(){
		super();
		System.out.println("constructor of GetShopListAction");
	}
	
	public ShopService getGetShopListService() {
		return getShopListService;
	}

	public void setGetShopListService(ShopService getShopListService) {
		this.getShopListService = getShopListService;
	}

	public void setShops(List<Shop> shopList) {
    	this.shops = shopList;
    }

    public List<Shop> getShops() {
       return shops;
    }
    
    public void setShopList_String(String [] shopList_String) {
    	this.shopList_String = shopList_String;
    }
    
    public String [] getShopList_String() {
    	return shopList_String;
    }
    
    public String execute() {
    	List<Shop> shopList = getShopListService.getShopList();
    	//将业务逻辑组件的返回值设置成该Action的属性
    	System.out.println("shop size="+shopList.size());
    	System.out.println(aa);
    	setShops(shopList);
    	String [] shopList_String = new String[shopList.size()];
    	for(int i=0;i<shopList.size();i++) {
    		shopList_String[i] = shopList.get(i).getName();
    	}
    	setShopList_String(shopList_String);
		return SUCCESS;
    }
}
